package com.bgs.controller;

import com.bgs.service.UserLogonService;
import com.bgs.tool.R;
import com.bgs.vo.RecyclingorderVo;
import com.bgs.vo.UserVo;
import com.tencentyun.TLSSigAPIv2;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserLogonController {
    @Autowired
    private UserLogonService userLogonService;

    private long expire = 60*60*24*7;


    @Value("${IMConfig.sdkAppId}")
    private long sdkAppId;

    @Value("${IMConfig.secretKey}")
    private String secretKey;


    @GetMapping("/getUserLogon")
    @ApiOperation(value = "骑手登录")
    public R getUserLogon(String phone,String password){
        UserVo userVo = userLogonService.getUserLogon(phone,password);
        TLSSigAPIv2 api = new TLSSigAPIv2(sdkAppId,secretKey);
        String UserSig=api.genSig(String.valueOf(userVo.getUserId()),expire);

        return R.ok().data("userVo",userVo).data("UserSig",UserSig);
    }
}
